<template>
	<view>
		<view class="all">
			<view style="float: right;" @click="huanyihuan">
				<u-tag text="换一换" type="success" closeable :show="show" @close="tagClick" />
			</view>
		<!-- 	<view class="out">
				<view v-if="tag.length>0" class="tag" @click="clicktag(n.id)"
					v-bind:style="{color: colorlist[(Math.floor(Math.random()*colorlist.length)+index)%Math.floor(Math.random()*colorlist.length)],fontSize:(fontSize*index)%(fontSize+index)+'px'}"
					v-for="(n,index) in tag">
					<view
						:style="{width:(Math.floor(Math.random()*25)+10)+'vw',height:(Math.floor(Math.random()*20)+20)+'vw'}"
						class="text">{{n.word}}</view>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tag: [],
				fontSize: Math.floor(Math.random() * 50),
				colorlist: ["#C01E22", "#0088cc", "#FF5E52", "#2CDB87", "#00D6AC", "#EA84FF", "#FDAC5F", "#FD77B2",
					"#0DAAEA", "#C38CFF", "#FF926F", "#8AC78F", "#C7C183", "#9370DB", "#2f889a", "#9e5ae2"
				],
				show: true,
				sprinboot: ''
			}
		},
		methods: {
			// clicktag: function(id) {
			// 	uni.request({
			// 		url: this.$springboot + 'admin/queryimagebytag',
			// 		data: {
			// 			'id': id
			// 		},
			// 		success(res) {
			// 			uni.navigateTo({
			// 				url: '../tagdetail/tagdetail?data=' + JSON.stringify(res.data)
			// 			})
			// 		}
			// 	})

			// },
			// tagClick(index) {
			// 	this.show = false;
			// },
			// huanyihuan: function() {
			// 	var that = this
			// 	uni.request({
			// 		url: that.$springboot + 'admin/querypartkeyword',
			// 		data: {
			// 			ishot: 'huan'
			// 		},
			// 		method: 'GET',
			// 		success(res) {
			// 			that.tag = that.randomSortArray(res.data)
			// 			that.fontSize = Math.floor(Math.random() * 50)
			// 		}
			// 	})
			// },

			randomSortArray(arr) {
				var len = arr.length;
				for (var i = len - 1; i >= 0; i--) {
					var randomIndex = Math.floor(Math.random() * (i +
						1));
					var temp = arr[randomIndex];
					arr[randomIndex] = arr[i];
					arr[i] = temp;
				}
				return arr;
			}
		},
		onLoad() {
			var that = this
			that.sprinboot = that.$springboot
			// uni.request({
			// 	url: that.springboot + 'admin/querypartkeyword',
			// 	data: {
			// 		ishot: 'true'
			// 	},
			// 	method: 'GET',
			// 	success(res) {
			// 		console.log("请求完毕")
			// 		that.tag = that.randomSortArray(res.data)
			// 	}
			// })
			wx.showShareMenu({
				withShareTicket: true,
				menus: ['shareAppMessage', 'shareTimeline']
			})
		},
		onShow() {
			const pages = getCurrentPages()
			const perpage = pages[pages.length - 1]
			perpage.onLoad()
		}
	}
</script>

<style>
	.out {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
	}

	.tag {
		display: flex;
		flex-direction: row;
	}

	.all {
		display: flex;
		flex-direction: column;
	}
</style>
